<?php
class CreateHtml {
	var $filepath;
	var $filename;
	
	function mkdir($prefix = 'htmls', $dirname = 'other') {
		$y = date ( 'Y' );
		$m = date ( 'm' );
		$d = date ( 'd' );
		$p = DIRECTORY_SEPARATOR;
		$filePath = ".." . $p . $prefix . $p . $dirname . $p . $y . $p . $m . $p . $d;
		$a = explode ( $p, $filePath );
		foreach ( $a as $dir ) {
			$path .= $dir . $p;
			if (! is_dir ( $path )) {
				@mkdir ( $path, 0755 );
			}
		}
		return $filePath . $p;
	}
	function start() {
		ob_start ();
	}
	function end($dirname = 'other', $htmlid = null, $postfix = '.html') {
		$info = ob_get_contents ();
		$fileId = $htmlid;
		$path = $this->mkdir ( 'htmls', $dirname );
		$this->filepath = $path;
		$fileName = $fileId . $postfix;
		$this->filename = $fileName;
		$file = fopen ( $path . $fileName, 'w ' );
		fwrite ( $file, $info );
		fclose ( $file );
		ob_end_flush ();
	}
}
?>